package com.shenma;

import com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@EnableAutoConfiguration
@ComponentScan
@ImportResource("classpath:dubbo-provider.xml")
@Configuration
public class Application  {

	public static void main(String[] args) {
		//SpringApplication.run(Application.class, args);
		new SpringApplicationBuilder(Application.class).run();

	}

	@Bean
	public ServletRegistrationBean dubboDispatcherServlet(){
		ServletRegistrationBean bean=new ServletRegistrationBean();
		bean.setServlet(new DispatcherServlet());
		bean.addUrlMappings("/foo/*");
		bean.setLoadOnStartup(1);

		return bean;
	}
}
